<template>
	<view class="goods_detail">
		<swiper indicator-dots>
			<swiper-item v-for="(item,index) in swipers" :key="index">
				<image :src="item.path"></image>
			</swiper-item>
		</swiper>
		<view class="box1">
			<view class="price">
				<text>￥2199</text>
				<text>￥2499</text>
			</view>
			<view class="goods_name">
				华为荣耀 6plus
			</view>
		</view>
		<view class="line"></view>
		<view class="box2">
			<view>货号：xxxxx</view>
			<view>库存：200</view>
		</view>
		<view class="line"></view>
		<view class="box3">
			<view class="tit">详情介绍</view>
			<view class="content">
				<!-- <rich-text :nodes="content"></rich-text> -->
				尼玛手机 值得拥有
			</view>
		</view>
		<view class="goods_nav">
			<uni-goods-nav :fill="true" :options="options" :buttonGroup="buttonGroup" @click="onClick" @buttonClick="buttonClick" />
		</view>

	</view>
</template>

<script>
	//引用uni-app的外部插件
	import uniGoodsNav from '@/components/uni-goods-nav/uni-goods-nav.vue'
	export default {
		data() {
			return {
				swipers: [{
						path: '../../static/shangpin/huawei6.jpg'
					},
					{
						path: '../../static/shangpin/huawei6.jpg'
					},
					{
						path: '../../static/shangpin/huawei6.jpg'
					}
				],
				info: {},
				content: '',
				id: 0,
				options: [{
					icon: 'headphones',
					text: '客服'
				}, {
					icon: 'shop',
					text: '店铺',
					info: 2,
					infoBackgroundColor: '#007aff',
					infoColor: "red"
				}, {
					icon: 'cart',
					text: '购物车',
					info: 2
				}],
				buttonGroup: [{
						text: '加入购物车',
						backgroundColor: '#ff0000',
						color: '#fff'
					},
					{
						text: '立即购买',
						backgroundColor: '#ffa200',
						color: '#fff'
					}
				]
			}
		},
		onLoad(option) {
			this.id = option.id
			//getSwiper()
			//getDetailInfo()
			//getDetailContent()
		},
		methods: {
			//获取轮播图
			async getSwiper() {
				const res = await this.$myRequest({
					url: '' + this.id
				})
				this.swipers = res.data.message
			},
			//获取数据
			async getDetailInfo() {
				const res = await this.$myRequest({
					url: '' + this.id
				})
				this.info = res.data.message[0]
			},
			async getDetailContent() {
				const res = await this.$myRequest({
					url: '' + this.id
				})
				this.content = res.data.message[0].content
			},
			//商品导航
			onClick(e) {
				uni.showToast({
					title: `点击${e.content.text}`,
					icon: 'none'
				})
			},
			buttonClick(e) {
				console.log(e)
				this.options[2].info++
			}
		},
		components: {
			uniGoodsNav
		}
	}
</script>

<style lang="scss">
	.goods_detail {
		swiper {
			height: 700rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.box1 {
			padding: 10px;

			.price {
				font-size: 35rpx;
				color: $shop-color;
				line-height: 80rpx; //行高

				text:nth-child(2) {
					color: #C0C0C0;
					font-size: 28rpx;
					text-decoration: line-through; //中划线
					margin-left: 20rpx;
				}
			}

			.goods_name {
				font-size: 32rpx;
				line-height: 60rpx;
			}
		}

		.box2 {
			padding: 0 10px;
			font-size: 32rpx;
			line-height: 70rpx;
		}

		.box3 {
			padding-bottom: 50px;//撑开50px,防止内容多的时候盖住
			.tit {
				font-size: 32rpx;
				padding-left: 10px;
				border-bottom: 1px solid #eee;
				line-height: 70rpx;
			}

			.content {
				padding: 10px;
				font-size: 28rpx;
				color: #333;
				line-height: 50rpx;
				//rich-text内容里的样式可以放到全局app.vue里面起作用
			}
		}
	}

	.goods_nav {
		position: fixed; //绝对定位
		bottom: 0;
		width: 100%;
	}

	.line {
		width: 750rpx;
		height: 10rpx;
		background-color: #eee;
	}
</style>
